package net.csdra.libraryborrowing.service.book;

import net.csdra.libraryborrowing.domain.book.BookInfo;
import net.csdra.libraryborrowing.domain.book.BookOrder;
import net.csdra.libraryborrowing.domain.book.BookStorageBox;
import net.csdra.libraryborrowing.domain.user.TransferBorrowInfo;
import net.csdra.libraryborrowing.domain.user.UserBorrow;
import net.csdra.libraryborrowing.service.PageEntity;
import org.springframework.data.domain.Page;

import java.awt.*;
import java.util.List;


/**
 * Created by msf on 2017/10/12.
 */
public interface BookServiceBAT {

    /**
     * 根据分类id获取书籍列表
     *
     * @param getBookListByCategory
     * @return
     */
    public Page<BookInfo> getBookListByCategory(GetBookListByCategory getBookListByCategory);

    /**
     * 根据书籍Id获取书籍
     *
     * @param getBookInfoById
     * @return
     */
    public BookInfo getBookInfoById(GetBookInfoById getBookInfoById);

    /**
     * 将书籍存入当前用户的购物车，购物车上限为100本书籍（非副本）
     *
     * @param putBookStorageBox
     * @return
     */
    public BookStorageBox putBookStorageBox(PutBookStorageBox putBookStorageBox);

    /**
     * 将书籍移除购物车，数据库硬删除
     *
     * @param removeBookStorageBox
     */
    public void removeBookStorageBox(RemoveBookStorageBox removeBookStorageBox);

    /**
     * 获取当前用户购物车的所有书籍
     *
     * @param gutBookStorageBox
     * @return
     */
    public Page<BookInfo> gutBookStorageBox(GutBookStorageBox gutBookStorageBox);

    /**
     * 用户发起借阅。
     * 新建一个BookOrder状态为WAITACCEPT
     * 设置consigneeUserId赋值为当用用户Id
     * 设置consigneeShippingAddressId为用户选择的收货地址Id     *
     * 创建一个BookOrderLog对象
     *
     * @param createBookOrder
     * @return
     */
    public BookOrder createBookOrder(CreateBookOrder createBookOrder);
//
//    /**
//     * 借阅者收货
//     * 输入参数handleState的值必须为COMPLETED或USERREJECTS，
//     * 订单的当前状态必须为DISTRIBUTION
//     * 将订单状态修改为handleState的值
//     * 创建BookOrderLog
//     *
//     * @param handleBookOrder
//     * @return
//     */
//    public BookOrder handleBookOrder(BookOrderManageService.HandleBookOrder handleBookOrder);

    /**
     * 确认到货
     * 将订单状态修改为COMPLETED，订单当前状态必须为DISTRIBUTION
     * 将订单对象所有副本状态修改为外借
     * 创建BookOrderLog
     *
     * @param acceptBookOrder
     * @return
     */
    public BookOrder acceptBookOrder(AcceptBookOrder acceptBookOrder);

    /**
     * 确认到货
     * 将订单状态修改为USERREJECTS，订单当前状态必须为DISTRIBUTION
     * 将订单对象所有副本状态修改为快递中
     * 创建BookOrderLog
     *
     * @param rejectBookOrder
     * @return
     */
    public BookOrder rejectBookOrder(RejectBookOrder rejectBookOrder);

    /**
     * 续借副本。
     * 副本状态必须为外借，userBorrowId必须属于当前用户，UserBorrow的结束时间必须晚于当前时间。并生成UserBorrowLog
     *
     * @param redecorate
     * @return
     */
    public UserBorrow redecorate(Redecorate redecorate);

    /**
     * 生成转借信息
     * bookCopyId必须属于当前用户
     * 创建TransferBorrowInfo，originUserId为当前用户Id，targetUserId为通过recipientUserName获取的用户Id，state设置为READY
     *
     * @param generateTransferBorrowInfo
     * @return
     */
    public TransferBorrowInfo generateTransferBorrowInfo(GenerateTransferBorrowInfo generateTransferBorrowInfo);

    /**
     * 处理转借信息
     * 根据transferBorrowInfoId获取TransferBorrowInfo，TransferBorrowInfo的targetUserId必须为当前用户Id，TransferBorrowInfo的state必须为READY
     * 创建当前用户的UserBorrow和UserBorrowLog
     *
     * @param handleTransferBorrowInfo
     * @return
     */
    public UserBorrow handleTransferBorrowInfo(HandleTransferBorrowInfo handleTransferBorrowInfo);

    class HandleTransferBorrowInfo {
        String transferBorrowInfoId;

        public String getTransferBorrowInfoId() {
            return transferBorrowInfoId;
        }

        public void setTransferBorrowInfoId(String transferBorrowInfoId) {
            this.transferBorrowInfoId = transferBorrowInfoId;
        }
    }


    class GetBookListByCategory extends PageEntity {
        List<String> categoryIds;

        public List<String> getCategoryIds() {
            return categoryIds;
        }

        public void setCategoryIds(List<String> categoryIds) {
            this.categoryIds = categoryIds;
        }
    }

    class GetBookInfoById {
        String bookInfoId;

        public String getBookInfoId() {
            return bookInfoId;
        }

        public void setBookInfoId(String bookInfoId) {
            this.bookInfoId = bookInfoId;
        }
    }

    class PutBookStorageBox {
        List<String> bookInfoIds;

        public List<String> getBookInfoIds() {
            return bookInfoIds;
        }

        public void setBookInfoIds(List<String> bookInfoIds) {
            this.bookInfoIds = bookInfoIds;
        }
    }

    class GutBookStorageBox extends PageEntity {
    }

    class RemoveBookStorageBox {
        List<String> bookStorageBoxids;

        public List<String> getBookStorageBoxids() {
            return bookStorageBoxids;
        }

        public void setBookStorageBoxids(List<String> bookStorageBoxids) {
            this.bookStorageBoxids = bookStorageBoxids;
        }
    }

    class CreateBookOrder {
        //订单书籍列表
        List<String> bookCopyIds;
        //收货人地址信息
        String consigneeShippingAddressId;
        String remark;

        public List<String> getBookCopyIds() {
            return bookCopyIds;
        }

        public void setBookCopyIds(List<String> bookCopyIds) {
            this.bookCopyIds = bookCopyIds;
        }

        public String getConsigneeShippingAddressId() {
            return consigneeShippingAddressId;
        }

        public void setConsigneeShippingAddressId(String consigneeShippingAddressId) {
            this.consigneeShippingAddressId = consigneeShippingAddressId;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }
    }

    class AcceptBookOrder {
        String bookOrderId;
        String remark;
    }

    class RejectBookOrder extends AcceptBookOrder {
    }

    class Redecorate {
        String userBorrowId;
        String remark;

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getUserBorrowId() {
            return userBorrowId;
        }

        public void setUserBorrowId(String userBorrowId) {
            this.userBorrowId = userBorrowId;
        }
    }

    class GenerateTransferBorrowInfo {
        //副本Id
        String bookCopyId;
        //接收转借者用户名
        String recipientUserName;
        //处理转借信息的地址
        String acceptUrl;

        public String getAcceptUrl() {
            return acceptUrl;
        }

        public void setAcceptUrl(String acceptUrl) {
            this.acceptUrl = acceptUrl;
        }

        public String getBookCopyId() {
            return bookCopyId;
        }

        public void setBookCopyId(String bookCopyId) {
            this.bookCopyId = bookCopyId;
        }

        public String getRecipientUserName() {
            return recipientUserName;
        }

        public void setRecipientUserName(String recipientUserName) {
            this.recipientUserName = recipientUserName;
        }
    }
}
